$(function(){
	var classify = {
			// 树设置.
			setting : {
				check: {
					enable: true,
					nocheckInherit: true
				},
				view:{
					selectedMulti: false
				},
				data: {
					simpleData: {
						enable: true
					}
				},
				async: {
					enable: true,
					url:GLOBAL.WEBROOT+"/systemMenu/nodedatas",
					type:"post",
					dataType:"json",
					autoParam: ["id"],
					dataFilter: null
					
				},
				callback:{
					onAsyncSuccess: onAsyncSuccess
				}
			   }
			};
	$.fn.zTree.init($("#tree"), classify.setting);
	 function onAsyncSuccess(){
		var menu = $("#power").val();
		if(menu){
			var treeObj = $.fn.zTree.getZTreeObj("tree");//树
			//装饰树
			var patt = new RegExp("^[0-9,]*$");//校验为纯数字
			if(menu&&menu.length>0&&patt.test(menu)){
				var arrMenu = menu.split(",");
				for(var i=0; i<arrMenu.length; i++){
					if(arrMenu[i]){
						var treeNode = treeObj.getNodeByParam("id", arrMenu[i],null);
						//console.log(treeNode);
						treeObj.checkNode(treeNode, true, false, false);
					}
					
					//treeObj.checkNode(treeNode, true, false, false);
				}
			}
		}
	};
	//power();
});